﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace CustomLesson.Controls
{
    /// <summary>
    /// GasFlowGauge.xaml 的交互逻辑
    /// </summary>
    public partial class GasFlowGauge : UserControl
    {
        public GasFlowGauge()
        {
            InitializeComponent();
        }

        public static readonly DependencyProperty ValueProperty =
            DependencyProperty.Register("Value", typeof(double), typeof(GasFlowGauge),
                new PropertyMetadata(0.0, OnValueChanged));

        public double Value
        {
            get { return (double)GetValue(ValueProperty); }
            set { SetValue(ValueProperty, value); }
        }

        private static void OnValueChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            var control = d as GasFlowGauge;
            control.UpdateGauge();
        }

        private void UpdateGauge()
        {
            ValueText.Text = Value.ToString("0");
            // 这里可以添加代码来更新仪表盘指针的旋转
        }
    }
}
